package com.hl.toolkit.pay.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    private static final Logger logger = LoggerFactory.getLogger(DataSourceConfig.class);

//	@Bean(name = "masterDataSource")
//	@Qualifier("masterDataSource")
//	@Primary
//	@ConfigurationProperties(prefix = "datasource.master")
//	public DataSource masterDataSource() {
//	    logger.info("-------------------- MasterDataSource init ---------------------");
//	    return DataSourceBuilder.create().build();
//	}
   
     @Bean(name = "slaveDataSource")
    @Qualifier("slaveDataSource")
    @ConfigurationProperties(prefix = "datasource.slave")
    public DataSource slaveDataSource() {
        logger.info("-------------------- SlaveDataSource init ---------------------");
        return DataSourceBuilder.create().build();
    }

}
